#!/usr/bin/env bash
set -ex

REPO="https://api.github.com/repos/rancher/rke2-upgrade/dispatches"

# send dispatch event to REPO
curl -XPOST -u "${PAT_USERNAME}:${PAT_TOKEN}" \
        -H "Accept: application/vnd.github.everest-preview+json"  \
        -H "Content-Type: application/json" $REPO \
        --data '{"event_type": "create_tag", "client_payload": {"tag":"'"$DRONE_TAG"'"}}'

SYSTEM_AGENT_INSTALLER_RKE2_REPO="https://api.github.com/repos/rancher/system-agent-installer-rke2/dispatches"

# send dispatch event to SYSTEM_AGENT_INSTALLER_RKE2_REPO
curl -XPOST -u "${PAT_USERNAME}:${PAT_TOKEN}" \
        -H "Accept: application/vnd.github.everest-preview+json"  \
        -H "Content-Type: application/json" $SYSTEM_AGENT_INSTALLER_RKE2_REPO \
        --data '{"event_type": "create_tag", "client_payload": {"tag":"'"$DRONE_TAG"'"}}'
